package cn.itlaobing.train.web.servlet;

import cn.itlaobing.train.service.Imp.TrainServiceImp;
import cn.itlaobing.train.service.TrainService;
import cn.itlaobing.train.web.anntation.RequestMapping;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created by Administrator on 2017/11/10.
 */
@WebServlet("/trainServlet/*")
public class TrainServlet extends BaseServlet {
    @RequestMapping("/login")
    public void login(HttpServletRequest request, HttpServletResponse response)throws ServletException,IOException {
        request.setCharacterEncoding("utf-8");
        String trainNum = request.getParameter("trainNum");
        String beginStation = request.getParameter("beginStation");
        String endStation = request.getParameter("endStation");
        System.out.print(beginStation);
        TrainService trainService = new TrainServiceImp();
        float sitePrice = trainService.queryBytrainNumAndTrainStation(trainNum, beginStation, endStation);

        request.getSession().setAttribute("trainNum", trainNum);
        request.getSession().setAttribute("beginStation", beginStation);
        request.getSession().setAttribute("endStation", endStation);
        request.getSession().setAttribute("sitePrice", sitePrice);
        toView(request, response, "/order/show");
    }
    @RequestMapping("/dump")
       public  void  dump(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException{
           redirectTo(response,"show.jsp");

    }
}
